package com.wyy;

import com.wyy.beans.Car;
import com.wyy.beans.Driver;
import org.junit.jupiter.api.Test;

import java.util.HashMap;

public class Demo01 {

    private static final double R = 6371393.0; //单位m

    @Test
    public void getDistance() {
        double parkLotLatitude = 113.11812; // 停车场纬度
        double parkLotLongitude = 36.694514; // 停车场经度
        double driverLatitude = 115.597805; // 司机纬度
        double driverLongitude = 35.738024; // 司机经度

        double parkLotRadian = radian(parkLotLatitude); // 弧度
        double driverRadian = radian(driverLatitude);
        double differenceLatitude = radian(parkLotLatitude) - radian(driverLatitude);//两点纬度之差
        double differenceLongitude = radian(parkLotLongitude) - radian(driverLongitude); //经度之差

        double distance = 2 * Math.asin(
                Math.sqrt(Math.pow(Math.sin(differenceLatitude / 2), 2)
                        + Math.cos(parkLotRadian) * Math.cos(driverRadian)
                        * Math.pow(Math.sin(differenceLongitude / 2), 2)));//计算两点距离的公式

        distance = distance * R;//弧长 * 地球半径
        distance = Math.round(distance * 10000) / 10000;//精确距离的数值
        System.out.println(distance);
    }

    public double radian (double latitudeOrLongitude) {
        return latitudeOrLongitude * Math.PI / 180.0;
    }

    @Test
    public void test2() {
        HashMap<Car, Driver> map = new HashMap<>();
        map.put(new Car(1L, "111","111"), new Driver(22222l,"1", "2", 1,"", ""));
        map.put(new Car(1L, "111","111"), new Driver(11l,"1", "2", 1,"", ""));
        map.put(new Car(2L, "222","111"), new Driver(11l,"1", "2", 1,"", ""));
        map.put(new Car(3l, "333","111"), new Driver(11l,"1", "2", 1,"", ""));

        System.out.println(map);
    }

    @Test
    public void test3 () {
        Integer a = 72000;
        Integer b = 73000;
        Integer discount = 50;
        Integer full = 100;
        Integer sum = a + b;
        int i = (a + b) / (full * 1000) * (discount * 1000);
        int i1 = a + b - i;
        int i2 =  i1 * a ;
        int l = i2 / sum;
        System.out.println(i1 + " " + sum + i2);
    }

}
